package com.gxa.service.investment.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.gxa.dto.investmentDto.BusinessTypeAllDto;
import com.gxa.dto.investmentDto.BusinessTypeDto;
import com.gxa.dto.investmentDto.IntentionRegisterQuitResult;
import com.gxa.entity.investment.BusinessType;
import com.gxa.mapper.investment.BusinessTypeMapper;
import com.gxa.service.investment.BusinessTypeService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.commons.collections.map.HashedMap;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;
import java.util.Set;

/**
 * <p>
 * 招商配置——行业类型 服务实现类
 * </p>
 *
 * @author yjl
 * @since 2022-10-17 09:11:43
 */
@Service
public class BusinessTypeServiceImpl extends ServiceImpl<BusinessTypeMapper, BusinessType> implements BusinessTypeService {
    @Autowired
    private BusinessTypeMapper businessTypeMapper;


    @Override
    public int add(BusinessType businessType) {
        return businessTypeMapper.insert(businessType);
    }

    @Override
    public int delete(Integer id) {
        return businessTypeMapper.deleteById(id);
    }

    @Override
    public BusinessType queryById(Integer id) {
        return null;
    }

    @Override
    public List<BusinessType> seletAll() {
        return null;
    }

    @Override
    public int update(BusinessType businessType) {
        return businessTypeMapper.updateById(businessType);
    }

    @Override
    public PageInfo queryByBusiness(String business, Integer pageNum, Integer pageSize) {
        Page<BusinessTypeDto> page = PageHelper.startPage(pageNum,pageSize);
        List<BusinessTypeDto> businessTypeDtoList = this.businessTypeMapper.queryByBusiness(business);
        PageInfo<BusinessTypeDto> pageInfo = new PageInfo<>(businessTypeDtoList);
//        for (BusinessTypeDto businessTypeDto:businessTypeDtoList) {
//            if (businessTypeDto.getChildNum()==0) {
//                businessTypeDtoList.remove(businessTypeDto);
//            }
//        }
        return pageInfo;
    }

    //下拉框去重
    @Override
    public Set<String> seletBusiness() {
        return businessTypeMapper.seletBusiness();
    }

    @Override
    public List<BusinessTypeAllDto> queryById(String coding) {
        List<BusinessTypeAllDto> list = this.businessTypeMapper.queryByCoding(coding);
        return list;
    }
}
